﻿using System.Web;
using System.Web.Mvc;
using Orange.Mvc4App.Models;
using Orange.Mvc4App.Models;
using Orange.Mvc4App.Services;
using System.ComponentModel;
using Orange.Mvc4App.Infrastructure;

namespace Orange.Mvc4App.Controllers
{
    public class ChargeController : BaseController
    {
        private readonly IChargeService service;

        public ChargeController(IChargeService service)
        {
            this.service = service;
        }

        public ActionResult Index(int pageIndex = 1)
        {
            ViewBag.Type = "All";
            return View(new PagedList<Charge>(
                service.GetList(null), pageIndex, pageSize));
        }

        [HttpPost]
        public ActionResult Index(HttpPostedFileBase file)
        {
            service.ReadFile(file);
            return View();
        }

        public ActionResult Success()
        {
            return View();
        }

        public ActionResult Water(int pageIndex = 1)
        {
            ViewBag.Type = "Water";
            return View("Index",new PagedList<Charge>(
                service.GetList(true), pageIndex, pageSize));
        }

        public ActionResult Elec(int pageIndex = 1)
        {
            ViewBag.Type = "Elec";
            return View("Index",new PagedList<Charge>(
                service.GetList(false), pageIndex, pageSize));
        }
    }
}